package com.xzt.meeting.dao;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.jdbc.core.JdbcTemplate;

import java.io.IOException;
import java.util.Properties;

/**
 * @Author xzt
 * @Date 2022/5/5 22:43
 * @Version 1.0
 * @Introduce
 */
public class BaseDao {
    public JdbcTemplate jdbcTemplate;

    public BaseDao() {
        DruidDataSource dataSource = new DruidDataSource();

        Properties prop = new Properties();
        try {
            prop.load(this.getClass().getClassLoader().getResourceAsStream("jdbc.properties"));
        } catch (IOException e) {
            e.printStackTrace();
        }

        dataSource.setUsername(prop.getProperty("jdbc.username"));
        dataSource.setPassword(prop.getProperty("jdbc.password"));
        dataSource.setUrl(prop.getProperty("jdbc.url"));
        dataSource.setDriverClassName(prop.getProperty("jdbc.driverClassName"));

        jdbcTemplate = new JdbcTemplate(dataSource);
    }
}
